package com.ailanyin.modules.file.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置静态文件资源服务器
 *
 * @author ailanyin
 * @version 1.0
 * @since 2022/2/28 0028 上午 9:12
 */
@Configuration
public class FileConfig implements WebMvcConfigurer {

    @Value("${ailanyin.uploadPath}")
    private String uploadPath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("file/**")
                .addResourceLocations("file:" + uploadPath);

    }
}
